<template>
  <div id="app">
    <!-- <nav>
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </nav> -->
    <transition name="slide">
      <Toast v-show="isShowtoast"></Toast>
    </transition>
    <Topbar :key="topbarKeyValue"></Topbar>
    <Header></Header>
    <router-view />

    <Login v-show="isShowLogin"></Login>
    <Footer></Footer>
  </div>
</template>

<script>
import Header from "@/components/Header.vue";
import Footer from "@/components/Footer.vue";
import Login from "@/components/Login.vue";
import Topbar from "@/components/Topbar.vue";
import Toast from "@/components/Toast.vue";
import { mapState } from "vuex";
import { JingpinAPI } from "@/request/api";
export default {
  components: {
    Topbar,
    Login,
    Footer,
    Header,
    Toast,
  },
  data(){
    return {
      topbarKeyValue:0
    }
  },
  watch:{
    '$route.path':{
      handler(newVal,oldVal){
        if(newVal !=oldVal){
          this.topbarKeyValue++
        }
      }
    }
  },
  async created() {
    let res = await JingpinAPI();
    // console.log(res);
  },
  computed: {
    ...mapState({
      isShowLogin: (state) => state.showModal.isShowLogin,
      isShowtoast: (state) => state.showtoast.isShowtoast,
    }),
  },
};
</script>


<style lang="less">
// #app {
//   font-family: Avenir, Helvetica, Arial, sans-serif;
//   -webkit-font-smoothing: antialiased;
//   -moz-osx-font-smoothing: grayscale;
//   text-align: center;
//   color: #2c3e50;
// }
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
